package com.itxiao.controller;

import com.itxiao.annotation.Token;
import com.itxiao.config.SystemConfig;
import com.itxiao.pojo.bo.Page;
import com.itxiao.pojo.dto.AddCollectDto;
import com.itxiao.pojo.dto.AddOrderDto;
import com.itxiao.pojo.vo.R;
import com.itxiao.service.OrderItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.List;

/**
 * (OrderItem)表控制层
 *
 * @author makejava
 * @since 2025-10-12 17:07:25
 */
@RestController
@RequestMapping("wx/api/v1/order")
@Api(tags = "订单模块")
@CrossOrigin
public class OrderItemController  {
    /**
     * 服务对象
     */
    @Resource
    private OrderItemService orderItemService;


    @ApiOperation("查询")
    @PostMapping("/list")
    @Token
    public R queryList(@RequestBody  Page page, HttpServletRequest request) {
        return orderItemService.queryList(page,request.getHeader(SystemConfig.HEADER_TOKEN));
    }
    @ApiOperation("查询订单状态分组")
    @PostMapping("/query-status")
    @Token
    public R queryStatus(HttpServletRequest request) {
        return orderItemService.queryStatus(request.getHeader(SystemConfig.HEADER_TOKEN));
    }
    @ApiOperation("查询订单详情")
    @GetMapping("/query-collect")
    @Token
    public R queryDetail( Integer id, HttpServletRequest request) {
        return orderItemService.queryDetail(id,request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    @ApiOperation("创建订单")
    @PostMapping("/add")
    @Token
    public R add(@RequestBody AddOrderDto dto, HttpServletRequest request) {
        return orderItemService.add(dto,request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    @ApiOperation("删除收藏")
    @DeleteMapping("/delete/{id}")
    @Token
    public R deleteById(@PathVariable Integer id) {
        return R.ok(orderItemService.removeById(id));
    }

}

